<!DOCTYPE HTML>
<html lang="zh-CN">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="分类: Go, 张亚飞,飞凡空间,国学,Python,Go">
    <meta name="description" content="分类: Go | 飞凡空间">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
	<meta name="baidu-site-verification" content="code-w2ezfaoXE0" />
    <title>分类: Go | 飞凡空间</title>
    <link rel="icon" type="image/png" href="/medias/my-logo.png">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/all.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">
    
    <script src="/libs/jquery/jquery.min.js"></script>
    
<meta name="generator" content="Hexo 5.2.0">
<style>.github-emoji { position: relative; display: inline-block; width: 1.2em; min-height: 1.2em; overflow: hidden; vertical-align: top; color: transparent; }  .github-emoji > span { position: relative; z-index: 10; }  .github-emoji img, .github-emoji .fancybox { margin: 0 !important; padding: 0 !important; border: none !important; outline: none !important; text-decoration: none !important; user-select: none !important; cursor: auto !important; }  .github-emoji img { height: 1.2em !important; width: 1.2em !important; position: absolute !important; left: 50% !important; top: 50% !important; transform: translate(-50%, -50%) !important; user-select: none !important; cursor: auto !important; } .github-emoji-fallback { color: inherit; } .github-emoji-fallback img { opacity: 0 !important; }</style>
<link rel="alternate" href="/atom.xml" title="飞凡空间" type="application/atom+xml">
<link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css">
<link rel="stylesheet" href="/css/prism-line-numbers.css" type="text/css"></head>


<body>
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                    <img src="/medias/my-logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">飞凡空间</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>首页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>标签</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>分类</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>归档</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>关于</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/friends" class="waves-effect waves-light">
      
      <i class="fas fa-address-book" style="zoom: 0.6;"></i>
      
      <span>友情链接</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/contact" class="waves-effect waves-light">
      
      <i class="fas fa-comments" style="zoom: 0.6;"></i>
      
      <span>留言板</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>

<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/my-logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">飞凡空间</div>
        <div class="logo-desc">
            
            诚者，天之道也；诚之者，人之道也。诚者，不勉而中，不思而得。从容中道，圣人也；诚之者，择善而固执者也。
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			首页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			标签
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			分类
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			归档
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			关于
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/friends" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-address-book"></i>
			
			友情链接
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/contact" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-comments"></i>
			
			留言板
		</a>
          
        </li>
        
        
    </ul>
</div>

        </div>

        
    </nav>

</header>

    <div class="bg-cover pd-header about-cover">
    <div class="container">
    <div class="row">
    <div class="col s10 offset-s1 m8 offset-m2 l8 offset-l2">
        <div class="brand">
            <div class="title center-align">
                
                择善固执，守正待时
                
            </div>

            <div class="description center-align">
                
                诚者，天之道也；诚之者，人之道也。诚者，不勉而中，不思而得。从容中道，圣人也；诚之者，择善而固执者也。
                
            </div>
        </div>
    </div>
</div>


<script>
    // 每天切换 banner 图.  Switch banner image every day.
    $('.bg-cover').css('background-image', 'url(/medias/banner/' + new Date().getDay() + '.jpg)');
</script>


    </div>
</div>

<main class="content">

    

<div id="category-cloud" class="container chip-container">
    <div class="card">
        <div class="card-content">
            <div class="tag-title center-align">
                <i class="fas fa-bookmark"></i>&nbsp;&nbsp;文章分类
            </div>
            <div class="tag-chips">
                
                
                
                <a href="/categories/Python/" title="Python: 46">
                    <span class="chip center-align waves-effect waves-light
                             chip-default "
                            style="background-color: #F9EBEA;">Python
                        <span class="tag-length">46</span>
                    </span>
                </a>
                
                
                <a href="/categories/Go/" title="Go: 34">
                    <span class="chip center-align waves-effect waves-light
                             chip-active "
                            style="background-color: #F5EEF8;">Go
                        <span class="tag-length">34</span>
                    </span>
                </a>
                
                
                <a href="/categories/Python/pandas/" title="pandas: 7">
                    <span class="chip center-align waves-effect waves-light
                             chip-default "
                            style="background-color: #D5F5E3;">pandas
                        <span class="tag-length">7</span>
                    </span>
                </a>
                
                
                <a href="/categories/Go/base/" title="base: 27">
                    <span class="chip center-align waves-effect waves-light
                             chip-default "
                            style="background-color: #E8F8F5;">base
                        <span class="tag-length">27</span>
                    </span>
                </a>
                
                
                <a href="/categories/Go/stdlib/" title="stdlib: 2">
                    <span class="chip center-align waves-effect waves-light
                             chip-default "
                            style="background-color: #FEF9E7;">stdlib
                        <span class="tag-length">2</span>
                    </span>
                </a>
                
                
                <a href="/categories/Go/Advanced/" title="Advanced: 3">
                    <span class="chip center-align waves-effect waves-light
                             chip-default "
                            style="background-color: #F8F9F9;">Advanced
                        <span class="tag-length">3</span>
                    </span>
                </a>
                
                
                <a href="/categories/Go/practice/" title="practice: 1">
                    <span class="chip center-align waves-effect waves-light
                             chip-default "
                            style="background-color: #82E0AA;">practice
                        <span class="tag-length">1</span>
                    </span>
                </a>
                
                
                <a href="/categories/Python/base/" title="base: 32">
                    <span class="chip center-align waves-effect waves-light
                             chip-default "
                            style="background-color: #D7BDE2;">base
                        <span class="tag-length">32</span>
                    </span>
                </a>
                
                
                <a href="/categories/Python/Advanced/" title="Advanced: 6">
                    <span class="chip center-align waves-effect waves-light
                             chip-default "
                            style="background-color: #A3E4D7;">Advanced
                        <span class="tag-length">6</span>
                    </span>
                </a>
                
                
                <a href="/categories/skill/" title="skill: 1">
                    <span class="chip center-align waves-effect waves-light
                             chip-default "
                            style="background-color: #85C1E9;">skill
                        <span class="tag-length">1</span>
                    </span>
                </a>
                
                
            </div>
        </div>
    </div>
</div>

    

    <article id="articles" class="container articles">
        <div class="row tags-posts">
            
            <div class="article tag-post col s12 m6 l4" data-aos="zoom-in">
                <div class="card">
                    <a href="/go/base/di-27-pian-protobuf-jian-ming-jiao-cheng/">
                        <div class="card-image tag-image">
                            
                            <img src="https://zhangyafei-1258643511.cos.ap-nanjing.myqcloud.com/Go/blog/27.jpg" class="responsive-img" alt="第27篇：ProtoBuf简明教程">
                            
                            <span class="card-title">第27篇：ProtoBuf简明教程</span>
                        </div>
                    </a>
                    <div class="card-content article-content">
                        <div class="summary block-with-text">
                            
                                1 Protocol Buffers 简介protobuf 即 Protocol Buffers，是一种轻便高效的结构化数据存储格式，与语言、平台无关，可扩展可序列化。protobuf 性能和效率大幅度优于 JSON、XML 等其他的结构化
                            
                        </div>
                        <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2021-01-27
                            </span>
                            <span class="publish-author">
                                
                                <i class="fas fa-bookmark fa-fw icon-category"></i>
                                
                                <a href="/categories/Go/" class="post-category">
                                    Go
                                </a>
                                
                                <a href="/categories/Go/base/" class="post-category">
                                    base
                                </a>
                                
                                
                            </span>
                        </div>
                    </div>

                    
                    <div class="card-action article-tags">
                        
                        <a href="/tags/Go%E4%B9%8B%E8%B7%AF/">
                            <span class="chip bg-color">Go之路</span>
                        </a>
                        
                        <a href="/tags/Protobuf/">
                            <span class="chip bg-color">Protobuf</span>
                        </a>
                        
                    </div>
                    
                </div>
            </div>
            
            <div class="article tag-post col s12 m6 l4" data-aos="zoom-in">
                <div class="card">
                    <a href="/go/base/di-26-pian-gin-jian-ming-jiao-cheng/">
                        <div class="card-image tag-image">
                            
                            <img src="https://zhangyafei-1258643511.cos.ap-nanjing.myqcloud.com/Go/blog/26.jpg" class="responsive-img" alt="第26篇：Gin简明教程">
                            
                            <span class="card-title">第26篇：Gin简明教程</span>
                        </div>
                    </a>
                    <div class="card-content article-content">
                        <div class="summary block-with-text">
                            
                                Gin 简介
Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance –
                            
                        </div>
                        <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2021-01-26
                            </span>
                            <span class="publish-author">
                                
                                <i class="fas fa-bookmark fa-fw icon-category"></i>
                                
                                <a href="/categories/Go/" class="post-category">
                                    Go
                                </a>
                                
                                <a href="/categories/Go/base/" class="post-category">
                                    base
                                </a>
                                
                                
                            </span>
                        </div>
                    </div>

                    
                    <div class="card-action article-tags">
                        
                        <a href="/tags/Go%E4%B9%8B%E8%B7%AF/">
                            <span class="chip bg-color">Go之路</span>
                        </a>
                        
                        <a href="/tags/Gin/">
                            <span class="chip bg-color">Gin</span>
                        </a>
                        
                    </div>
                    
                </div>
            </div>
            
            <div class="article tag-post col s12 m6 l4" data-aos="zoom-in">
                <div class="card">
                    <a href="/go/advanced/zi-fu-chuan-pin-jie-xing-neng-ji-yuan-li/">
                        <div class="card-image tag-image">
                            
                            <img src="https://zhangyafei-1258643511.cos.ap-nanjing.myqcloud.com/Go/blog/%E8%BF%9B%E9%98%B6%E7%AF%873.jpg" class="responsive-img" alt="进阶篇：字符串拼接性能及原理">
                            
                            <span class="card-title">进阶篇：字符串拼接性能及原理</span>
                        </div>
                    </a>
                    <div class="card-content article-content">
                        <div class="summary block-with-text">
                            
                                一、字符串高效拼接在 Go 语言中，字符串(string) 是不可变的，拼接字符串事实上是创建了一个新的字符串对象。如果代码中存在大量的字符串拼接，对性能会产生严重的影响。
1. 常见的拼接方式为了避免编译器优化，我们首先实现一个生成长度为
                            
                        </div>
                        <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2021-01-13
                            </span>
                            <span class="publish-author">
                                
                                <i class="fas fa-bookmark fa-fw icon-category"></i>
                                
                                <a href="/categories/Go/" class="post-category">
                                    Go
                                </a>
                                
                                <a href="/categories/Go/Advanced/" class="post-category">
                                    Advanced
                                </a>
                                
                                
                            </span>
                        </div>
                    </div>

                    
                    <div class="card-action article-tags">
                        
                        <a href="/tags/Go%E4%B9%8B%E8%B7%AF/">
                            <span class="chip bg-color">Go之路</span>
                        </a>
                        
                        <a href="/tags/%E8%BF%9B%E9%98%B6%E7%AF%87/">
                            <span class="chip bg-color">进阶篇</span>
                        </a>
                        
                        <a href="/tags/%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%8B%BC%E6%8E%A5/">
                            <span class="chip bg-color">字符串拼接</span>
                        </a>
                        
                        <a href="/tags/%E9%AB%98%E6%80%A7%E8%83%BD%E7%BC%96%E7%A8%8B/">
                            <span class="chip bg-color">高性能编程</span>
                        </a>
                        
                    </div>
                    
                </div>
            </div>
            
            <div class="article tag-post col s12 m6 l4" data-aos="zoom-in">
                <div class="card">
                    <a href="/go/advanced/ti-gao-fan-she-xing-neng/">
                        <div class="card-image tag-image">
                            
                            <img src="https://zhangyafei-1258643511.cos.ap-nanjing.myqcloud.com/Go/blog/%E8%BF%9B%E9%98%B6%E7%AF%872.jpg" class="responsive-img" alt="进阶篇：提高反射性能">
                            
                            <span class="card-title">进阶篇：提高反射性能</span>
                        </div>
                    </a>
                    <div class="card-content article-content">
                        <div class="summary block-with-text">
                            
                                一、反射的用途标准库 reflect 为 Go 语言提供了运行时动态获取对象的类型和值以及动态创建对象的能力。反射可以帮助抽象和简化代码，提高开发效率。
Go 语言标准库以及很多开源软件中都使用了 Go 语言的反射能力，例如用于序列化和反序
                            
                        </div>
                        <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2021-01-12
                            </span>
                            <span class="publish-author">
                                
                                <i class="fas fa-bookmark fa-fw icon-category"></i>
                                
                                <a href="/categories/Go/" class="post-category">
                                    Go
                                </a>
                                
                                <a href="/categories/Go/Advanced/" class="post-category">
                                    Advanced
                                </a>
                                
                                
                            </span>
                        </div>
                    </div>

                    
                    <div class="card-action article-tags">
                        
                        <a href="/tags/Go%E4%B9%8B%E8%B7%AF/">
                            <span class="chip bg-color">Go之路</span>
                        </a>
                        
                        <a href="/tags/%E5%8F%8D%E5%B0%84/">
                            <span class="chip bg-color">反射</span>
                        </a>
                        
                        <a href="/tags/%E8%BF%9B%E9%98%B6%E7%AF%87/">
                            <span class="chip bg-color">进阶篇</span>
                        </a>
                        
                        <a href="/tags/%E9%AB%98%E6%80%A7%E8%83%BD%E7%BC%96%E7%A8%8B/">
                            <span class="chip bg-color">高性能编程</span>
                        </a>
                        
                    </div>
                    
                </div>
            </div>
            
            <div class="article tag-post col s12 m6 l4" data-aos="zoom-in">
                <div class="card">
                    <a href="/go/advanced/qie-pian-chuan-can-de-xian-jing/">
                        <div class="card-image tag-image">
                            
                            <img src="https://zhangyafei-1258643511.cos.ap-nanjing.myqcloud.com/Go/blog/%E8%BF%9B%E9%98%B6%E7%AF%871.jpg" class="responsive-img" alt="进阶篇：切片传参的陷阱">
                            
                            <span class="card-title">进阶篇：切片传参的陷阱</span>
                        </div>
                    </a>
                    <div class="card-content article-content">
                        <div class="summary block-with-text">
                            
                                问题引入在Go的源码库或者其他开源项目中，会发现有些函数在需要用到切片入参时，它采用是指向切片类型的指针，而非切片类型。这里未免会产生疑问：切片底层不就是指针指向底层数组数据吗，为何不直接传递切片，两者有什么区别？
例如，在源码log包中，
                            
                        </div>
                        <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2021-01-11
                            </span>
                            <span class="publish-author">
                                
                                <i class="fas fa-bookmark fa-fw icon-category"></i>
                                
                                <a href="/categories/Go/" class="post-category">
                                    Go
                                </a>
                                
                                <a href="/categories/Go/Advanced/" class="post-category">
                                    Advanced
                                </a>
                                
                                
                            </span>
                        </div>
                    </div>

                    
                    <div class="card-action article-tags">
                        
                        <a href="/tags/Go%E4%B9%8B%E8%B7%AF/">
                            <span class="chip bg-color">Go之路</span>
                        </a>
                        
                        <a href="/tags/%E5%88%87%E7%89%87/">
                            <span class="chip bg-color">切片</span>
                        </a>
                        
                        <a href="/tags/%E8%BF%9B%E9%98%B6%E7%AF%87/">
                            <span class="chip bg-color">进阶篇</span>
                        </a>
                        
                        <a href="/tags/%E4%BC%A0%E5%8F%82/">
                            <span class="chip bg-color">传参</span>
                        </a>
                        
                        <a href="/tags/%E9%99%B7%E9%98%B1/">
                            <span class="chip bg-color">陷阱</span>
                        </a>
                        
                    </div>
                    
                </div>
            </div>
            
            <div class="article tag-post col s12 m6 l4" data-aos="zoom-in">
                <div class="card">
                    <a href="/go/stdlib/log/">
                        <div class="card-image tag-image">
                            
                            <img src="https://zhangyafei-1258643511.cos.ap-nanjing.myqcloud.com/Go/blog/log.jpg" class="responsive-img" alt="标准库：log">
                            
                            <span class="card-title">标准库：log</span>
                        </div>
                    </a>
                    <div class="card-content article-content">
                        <div class="summary block-with-text">
                            
                                无论是软件开发的调试阶段还是软件上线之后的运行阶段，日志一直都是非常重要的一个环节，我们也应该养成在程序中记录日志的好习惯。
Go语言内置的log包实现了简单的日志服务。本文介绍了标准库log的基本使用。
一、使用Loggerlog包定义了
                            
                        </div>
                        <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2021-01-10
                            </span>
                            <span class="publish-author">
                                
                                <i class="fas fa-bookmark fa-fw icon-category"></i>
                                
                                <a href="/categories/Go/" class="post-category">
                                    Go
                                </a>
                                
                                <a href="/categories/Go/stdlib/" class="post-category">
                                    stdlib
                                </a>
                                
                                
                            </span>
                        </div>
                    </div>

                    
                    <div class="card-action article-tags">
                        
                        <a href="/tags/Go%E4%B9%8B%E8%B7%AF/">
                            <span class="chip bg-color">Go之路</span>
                        </a>
                        
                        <a href="/tags/%E6%A0%87%E5%87%86%E5%BA%93/">
                            <span class="chip bg-color">标准库</span>
                        </a>
                        
                        <a href="/tags/log/">
                            <span class="chip bg-color">log</span>
                        </a>
                        
                    </div>
                    
                </div>
            </div>
            
            <div class="article tag-post col s12 m6 l4" data-aos="zoom-in">
                <div class="card">
                    <a href="/go/stdlib/fmt/">
                        <div class="card-image tag-image">
                            
                            <img src="https://zhangyafei-1258643511.cos.ap-nanjing.myqcloud.com/Go/blog/fmt.jpg" class="responsive-img" alt="标准库：fmt">
                            
                            <span class="card-title">标准库：fmt</span>
                        </div>
                    </a>
                    <div class="card-content article-content">
                        <div class="summary block-with-text">
                            
                                fmt标准库是我们在学习Go语言过程中接触最早最频繁的一个了，本文介绍了fmtb包的一些常用函数。
fmt包实现了类似C语言printf和scanf的格式化I/O。主要分为向外输出内容和获取输入内容两大部分。
一、向外输出标准库fmt提供了
                            
                        </div>
                        <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2021-01-09
                            </span>
                            <span class="publish-author">
                                
                                <i class="fas fa-bookmark fa-fw icon-category"></i>
                                
                                <a href="/categories/Go/" class="post-category">
                                    Go
                                </a>
                                
                                <a href="/categories/Go/stdlib/" class="post-category">
                                    stdlib
                                </a>
                                
                                
                            </span>
                        </div>
                    </div>

                    
                    <div class="card-action article-tags">
                        
                        <a href="/tags/Go%E4%B9%8B%E8%B7%AF/">
                            <span class="chip bg-color">Go之路</span>
                        </a>
                        
                        <a href="/tags/%E6%A0%87%E5%87%86%E5%BA%93/">
                            <span class="chip bg-color">标准库</span>
                        </a>
                        
                        <a href="/tags/fmt/">
                            <span class="chip bg-color">fmt</span>
                        </a>
                        
                    </div>
                    
                </div>
            </div>
            
            <div class="article tag-post col s12 m6 l4" data-aos="zoom-in">
                <div class="card">
                    <a href="/go/base/di-25-pian-dan-yuan-ce-shi/">
                        <div class="card-image tag-image">
                            
                            <img src="https://zhangyafei-1258643511.cos.ap-nanjing.myqcloud.com/Go/blog/25.jpg" class="responsive-img" alt="第25篇：单元测试">
                            
                            <span class="card-title">第25篇：单元测试</span>
                        </div>
                    </a>
                    <div class="card-content article-content">
                        <div class="summary block-with-text">
                            
                                一、如何写好单元测试单元测试(Unit Tests, UT) 是一个优秀项目不可或缺的一部分，特别是在一些频繁变动和多人合作开发的项目中尤为重要。你或多或少都会有因为自己的提交，导致应用挂掉或服务宕机的经历。如果这个时候你的修改导致测试用例
                            
                        </div>
                        <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2021-01-08
                            </span>
                            <span class="publish-author">
                                
                                <i class="fas fa-bookmark fa-fw icon-category"></i>
                                
                                <a href="/categories/Go/" class="post-category">
                                    Go
                                </a>
                                
                                <a href="/categories/Go/base/" class="post-category">
                                    base
                                </a>
                                
                                
                            </span>
                        </div>
                    </div>

                    
                    <div class="card-action article-tags">
                        
                        <a href="/tags/Go%E4%B9%8B%E8%B7%AF/">
                            <span class="chip bg-color">Go之路</span>
                        </a>
                        
                        <a href="/tags/%E5%8D%95%E5%85%83%E6%B5%8B%E8%AF%95/">
                            <span class="chip bg-color">单元测试</span>
                        </a>
                        
                    </div>
                    
                </div>
            </div>
            
            <div class="article tag-post col s12 m6 l4" data-aos="zoom-in">
                <div class="card">
                    <a href="/go/base/di-24-pian-http-bian-cheng/">
                        <div class="card-image tag-image">
                            
                            <img src="https://zhangyafei-1258643511.cos.ap-nanjing.myqcloud.com/Go/blog/24.jpg" class="responsive-img" alt="第24篇：http编程">
                            
                            <span class="card-title">第24篇：http编程</span>
                        </div>
                    </a>
                    <div class="card-content article-content">
                        <div class="summary block-with-text">
                            
                                一、web工作流程
Web服务器的工作原理可以简单地归纳为
客户机通过TCP/IP协议建立到服务器的TCP连接
客户端向服务器发送HTTP协议请求包，请求服务器里的资源文档
服务器向客户机发送HTTP协议应答包，如果请求的资源包含有动态语言
                            
                        </div>
                        <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2021-01-07
                            </span>
                            <span class="publish-author">
                                
                                <i class="fas fa-bookmark fa-fw icon-category"></i>
                                
                                <a href="/categories/Go/" class="post-category">
                                    Go
                                </a>
                                
                                <a href="/categories/Go/base/" class="post-category">
                                    base
                                </a>
                                
                                
                            </span>
                        </div>
                    </div>

                    
                    <div class="card-action article-tags">
                        
                        <a href="/tags/Go%E4%B9%8B%E8%B7%AF/">
                            <span class="chip bg-color">Go之路</span>
                        </a>
                        
                        <a href="/tags/%E7%BD%91%E7%BB%9C%E7%BC%96%E7%A8%8B/">
                            <span class="chip bg-color">网络编程</span>
                        </a>
                        
                        <a href="/tags/http/">
                            <span class="chip bg-color">http</span>
                        </a>
                        
                    </div>
                    
                </div>
            </div>
            
            <div class="article tag-post col s12 m6 l4" data-aos="zoom-in">
                <div class="card">
                    <a href="/go/base/di-23-pian-socket-bian-cheng/">
                        <div class="card-image tag-image">
                            
                            <img src="https://zhangyafei-1258643511.cos.ap-nanjing.myqcloud.com/Go/blog/23.jpg" class="responsive-img" alt="第23篇：socket编程">
                            
                            <span class="card-title">第23篇：socket编程</span>
                        </div>
                    </a>
                    <div class="card-content article-content">
                        <div class="summary block-with-text">
                            
                                一、互联网协议介绍互联网的核心是一系列协议，总称为”互联网协议”（Internet Protocol Suite），正是这一些协议规定了电脑如何连接和组网。我们理解了这些协议，就理解了互联网的原理。由于这些协议太过庞大和复杂，没有办法在这里
                            
                        </div>
                        <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2021-01-06
                            </span>
                            <span class="publish-author">
                                
                                <i class="fas fa-bookmark fa-fw icon-category"></i>
                                
                                <a href="/categories/Go/" class="post-category">
                                    Go
                                </a>
                                
                                <a href="/categories/Go/base/" class="post-category">
                                    base
                                </a>
                                
                                
                            </span>
                        </div>
                    </div>

                    
                    <div class="card-action article-tags">
                        
                        <a href="/tags/Go%E4%B9%8B%E8%B7%AF/">
                            <span class="chip bg-color">Go之路</span>
                        </a>
                        
                        <a href="/tags/%E7%BD%91%E7%BB%9C%E7%BC%96%E7%A8%8B/">
                            <span class="chip bg-color">网络编程</span>
                        </a>
                        
                        <a href="/tags/socket/">
                            <span class="chip bg-color">socket</span>
                        </a>
                        
                    </div>
                    
                </div>
            </div>
            
            <div class="article tag-post col s12 m6 l4" data-aos="zoom-in">
                <div class="card">
                    <a href="/go/base/di-22-pian-context/">
                        <div class="card-image tag-image">
                            
                            <img src="https://zhangyafei-1258643511.cos.ap-nanjing.myqcloud.com/Go/blog/22.jpg" class="responsive-img" alt="第22篇：context">
                            
                            <span class="card-title">第22篇：context</span>
                        </div>
                    </a>
                    <div class="card-content article-content">
                        <div class="summary block-with-text">
                            
                                在 Go http包的Server中，每一个请求在都有一个对应的 goroutine 去处理。请求处理函数通常会启动额外的 goroutine 用来访问后端服务，比如数据库和RPC服务。用来处理一个请求的 goroutine 通常需要访问一
                            
                        </div>
                        <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2021-01-05
                            </span>
                            <span class="publish-author">
                                
                                <i class="fas fa-bookmark fa-fw icon-category"></i>
                                
                                <a href="/categories/Go/" class="post-category">
                                    Go
                                </a>
                                
                                <a href="/categories/Go/base/" class="post-category">
                                    base
                                </a>
                                
                                
                            </span>
                        </div>
                    </div>

                    
                    <div class="card-action article-tags">
                        
                        <a href="/tags/Go%E4%B9%8B%E8%B7%AF/">
                            <span class="chip bg-color">Go之路</span>
                        </a>
                        
                        <a href="/tags/%E5%B9%B6%E5%8F%91%E7%BC%96%E7%A8%8B/">
                            <span class="chip bg-color">并发编程</span>
                        </a>
                        
                        <a href="/tags/context/">
                            <span class="chip bg-color">context</span>
                        </a>
                        
                    </div>
                    
                </div>
            </div>
            
            <div class="article tag-post col s12 m6 l4" data-aos="zoom-in">
                <div class="card">
                    <a href="/go/base/di-21-pian-gmp-yuan-li-yu-diao-du/">
                        <div class="card-image tag-image">
                            
                            <img src="https://zhangyafei-1258643511.cos.ap-nanjing.myqcloud.com/Go/blog/21.jpg" class="responsive-img" alt="第21篇：GMP原理与调度">
                            
                            <span class="card-title">第21篇：GMP原理与调度</span>
                        </div>
                    </a>
                    <div class="card-content article-content">
                        <div class="summary block-with-text">
                            
                                一、Golang “调度器” 的由来？1. 单进程时代不需要调度器我们知道，一切的软件都是跑在操作系统上，真正用来干活 (计算) 的是 CPU。早期的操作系统每个程序就是一个进程，知道一个程序运行完，才能进行下一个进程，就是 “单进程时代”
                            
                        </div>
                        <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2021-01-04
                            </span>
                            <span class="publish-author">
                                
                                <i class="fas fa-bookmark fa-fw icon-category"></i>
                                
                                <a href="/categories/Go/" class="post-category">
                                    Go
                                </a>
                                
                                <a href="/categories/Go/base/" class="post-category">
                                    base
                                </a>
                                
                                
                            </span>
                        </div>
                    </div>

                    
                    <div class="card-action article-tags">
                        
                        <a href="/tags/Go%E4%B9%8B%E8%B7%AF/">
                            <span class="chip bg-color">Go之路</span>
                        </a>
                        
                        <a href="/tags/%E5%B9%B6%E5%8F%91%E7%BC%96%E7%A8%8B/">
                            <span class="chip bg-color">并发编程</span>
                        </a>
                        
                        <a href="/tags/GMP/">
                            <span class="chip bg-color">GMP</span>
                        </a>
                        
                    </div>
                    
                </div>
            </div>
            
        </div>
    </article>
</main>


<div class="container paging">
    <div class="row">
        <div class="col s6 m4 l4">
            
            <a class="left btn-floating btn-large disabled">
                <i class="fas fa-angle-left"></i>
            </a>
            
        </div>
        <div class="page-info col m4 l4 hide-on-small-only">
            <div class="center-align b-text-gray">1 / 3</div>
        </div>
        <div class="col s6 m4 l4">
            
            <a href="/categories/Go/page/2/"
               class="right btn-floating btn-large waves-effect waves-light bg-color">
                <i class="fas fa-angle-right"></i>
            </a>
            
        </div>
    </div>
</div>




    <footer class="page-footer bg-color">
    <div class="container row center-align">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            <span id="year">年份</span>
            <a href="https://zhangyafeii.gitee.io" target="_blank">张亚飞</a>
            |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
            |&nbsp;Theme&nbsp;<a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">Matery</a>
            <br>
            
            &nbsp;<i class="fas fa-chart-area"></i>&nbsp;站点总字数:&nbsp;<span
                class="white-color">344.5k</span>&nbsp;字
            
            
            
            
            
            
            <span id="busuanzi_container_site_pv">
                |&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;<span id="busuanzi_value_site_pv"
                    class="white-color"></span>&nbsp;次
            </span>
            
            
            <span id="busuanzi_container_site_uv">
                |&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;<span id="busuanzi_value_site_uv"
                    class="white-color"></span>&nbsp;人
            </span>
            
            <br>
            
            <span id="sitetime">载入运行时间...</span>
            <script>
                function siteTime() {
                    window.setTimeout("siteTime()", 1000);
                    var seconds = 1000;
                    var minutes = seconds * 60;
                    var hours = minutes * 60;
                    var days = hours * 24;
                    var years = days * 365;
                    var today = new Date();
                    var startYear = "2020";
                    var startMonth = "12";
                    var startDate = "18";
                    var startHour = "12";
                    var startMinute = "12";
                    var startSecond = "12";
                    var todayYear = today.getFullYear();
                    var todayMonth = today.getMonth() + 1;
                    var todayDate = today.getDate();
                    var todayHour = today.getHours();
                    var todayMinute = today.getMinutes();
                    var todaySecond = today.getSeconds();
                    var t1 = Date.UTC(startYear, startMonth, startDate, startHour, startMinute, startSecond);
                    var t2 = Date.UTC(todayYear, todayMonth, todayDate, todayHour, todayMinute, todaySecond);
                    var diff = t2 - t1;
                    var diffYears = Math.floor(diff / years);
                    var diffDays = Math.floor((diff / days) - diffYears * 365);
                    var diffHours = Math.floor((diff - (diffYears * 365 + diffDays) * days) / hours);
                    var diffMinutes = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours) /
                        minutes);
                    var diffSeconds = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours -
                        diffMinutes * minutes) / seconds);
                    if (startYear == todayYear) {
                        document.getElementById("year").innerHTML = todayYear;
                        document.getElementById("sitetime").innerHTML = "本站已安全运行 " + diffDays + " 天 " + diffHours +
                            " 小时 " + diffMinutes + " 分钟 " + diffSeconds + " 秒";
                    } else {
                        document.getElementById("year").innerHTML = startYear + " - " + todayYear;
                        document.getElementById("sitetime").innerHTML = "本站已安全运行 " + diffYears + " 年 " + diffDays +
                            " 天 " + diffHours + " 小时 " + diffMinutes + " 分钟 " + diffSeconds + " 秒";
                    }
                }
                setInterval(siteTime, 1000);
            </script>
            
            <br>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://github.com/zhangyafeii" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fab fa-github"></i>
    </a>



    <a href="https://gitee.com/zhangyafeii" class="tooltipped" target="_blank" data-tooltip="访问我的Gitee" data-position="top" data-delay="50">
        <i class="fab fa-google-plus"></i>
    </a>



    <a href="mailto:zhangyafeii@foxmail.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>







    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=1271570224" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 1271570224" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>







    <a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fas fa-rss"></i>
    </a>

</div>
    </div>
</footer>

<div class="progress-bar"></div>


    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script src="/js/search.js"></script>
<script type="text/javascript">
$(function () {
    searchFunc("/" + "search.xml", 'searchInput', 'searchResult');
});
</script>
    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/libs/materialize/materialize.min.js"></script>
    <script src="/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/libs/aos/aos.js"></script>
    <script src="/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/js/matery.js"></script>
    <script src="/js/cursor.js"></script>

    <!-- Global site tag (gtag.js) - Google Analytics -->


    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/libs/others/busuanzi.pure.mini.js"></script>
    

    

    

    

    

    
    <script type="text/javascript" src="/libs/background/ribbon-dynamic.js" async="async"></script>
    
    
    
    <script src="/libs/instantpage/instantpage.js" type="module"></script>
    

</body>

</html>
